package com.bjsxt.exception1;

import java.util.InputMismatchException;
import java.util.Scanner;

public class TestException4 {

    public static void main(String[] args) {

        try {
            //1.输入总分
            System.out.println("请输入总分：");
            Scanner input = new Scanner(System.in);
            int totalScore = input.nextInt();       //!!

            //2.输入人数
            System.out.println("请输入人数：");
            int number = input.nextInt();       //!!

            //3.计算平均分并输出
            int averageScore = totalScore / number;        //!!
            System.out.println("平均分：" + averageScore);

            return;     //退出当前方法

            //从上往下匹配，匹配异常成功，就停止匹配，抛出异常
        } catch (ArithmeticException e) {
            System.out.println("除数为0！");

        } catch (InputMismatchException e) {
            System.out.println("输入数据不是整数！");

        } catch (Exception e) {
            System.out.println("其他异常！");

        } finally {
            System.out.println("计算完毕！");
        }

        System.out.println("程序结束！");

    }
}
